package com.tongji.housediy.view.renderer
{
	import com.tongji.housediy.events.brandEvent.GetGoodsByBrandEvent;
	import com.tongji.housediy.model.BrandModel;
	import com.tongji.housediy.model.CompEnableStateModel;
	import com.tongji.housediy.model.ExchangeDataModel;
	import com.tongji.housediy.vo.Brand;
	
	import flash.display.Bitmap;
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	import mx.controls.Image;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/5/06
	 */ 
	public class BrandItemRentererMediator extends Mediator
	{
		[Inject]
		public var view:BrandItemRenterer;
		
		[Inject]
		public var brandModel:BrandModel;
				
		[Inject]
		public var currentStateModel:CompEnableStateModel;
		
		[Inject]
		public var roomModel:ExchangeDataModel;
		
		override public function onRegister():void
		{
			view..addEventListener(MouseEvent.CLICK, getGoodsByBrandHandler);
		}
		
		/**
		 * 获取被点击品牌的所有商品
		 * @param event
		 * 
		 */		
		private function getGoodsByBrandHandler(event:MouseEvent):void
		{
            dispatch(new GetGoodsByBrandEvent(GetGoodsByBrandEvent.GET_GOODS_BY_BRANDID, view.data.brandID));
			
			brandModel.currentBrand = view.data as Brand;
			brandModel.setSelectedIndex(view.data as Brand);
			
			currentStateModel.stateIndex = 1;
			currentStateModel.brandStateIndex = 0;
		}
	}
}